﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        <form id="form">
            foo：<input type="text" name="foo" value="foo" />
            zoo：<input type="text" name="zoo" value="zoo" /><br />
            bar：<input type="text" name="bar" value="bar" />
            baz：<input type="text" name="baz" value="baz" /><br />
            zooEntity.zoo：<input type="text" name="zooEntity.zoo" value="zooEntity.zoo" /><br />
            zooEntity.bar：<input type="text" name="zooEntity.bar" value="zooEntity.bar" />
            zooEntity.baz：<input type="text" name="zooEntity.baz" value="zooEntity.baz" /><br />
            <input type="button" id="btn_submit" value="提交" />
        </form>
    </div>
    <script src="~/Content/js/jquery-1.8.2.js"></script>
    <script src="~/Content/js/tjzheng.js"></script>
    <script type="text/javascript">
        $("#btn_submit").click(function () {
            var objFormEntity = new FormEntity("#form");
            objFormEntity.submiting = function () {
                var objFormData = objFormEntity.formData;
                if (!objFormData.foo) {
                    alert("foo不能为空");
                    return false;
                }
                if (!objFormData.zoo) {
                    alert("zoo不能为空");
                    return false;
                }
                if (!objFormData.bar) {
                    alert("bar不能为空");
                    return false;
                }
                if (!objFormData.baz) {
                    alert("baz不能为空");
                    return false;
                }
                if (!objFormData["zooEntity.zoo"]) {
                    alert("zooEntity.zoo不能为空");
                    return false;
                }
                if (!objFormData["zooEntity.bar"]) {
                    alert("zooEntity.bar不能为空");
                    return false;
                }
                if (!objFormData["zooEntity.baz"]) {
                    alert("zooEntity.baz不能为空");
                    return false;
                }
                return true;
            }
            var i = 0;
            //objFormEntity.async = true;
            objFormEntity.async = false
            objFormEntity.submitSuccess = function (data) {
                i++;
            }
            objFormEntity.isClearData = false;
            //objFormEntity.url = "/Home/PostParams";
            objFormEntity.url = "/Ajax/PostComplicatedEntity";
            objFormEntity.submit();
            if (i == 1) {
                alert("标记");
            }
        });
    </script>
</body>
</html>
